package com.jqq.spring.service.impl;

import com.jqq.spring.service.BookService;
import com.jqq.spring.service.CheckoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 姬倩倩
 * @date 2023-05-22
 */
@Service
public class CheckoutServiceImpl implements CheckoutService {
    @Autowired
    private BookService bookService;
    @Transactional
    //一次购买多本图书
    @Override
    public void checkout(Integer userId, Integer[] bookIds) {
        for (Integer bookId : bookIds){
            bookService.buyBook(userId, bookId);
        }
    }
}

